<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/layouts/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>${displayName}</title>
	<link rel="stylesheet" href="${r'${staticPath}'}/admin/tcsf/reset.css" />
	<link href="${r'${staticPath}'}/admin/iconfont/iconfont.css" type="text/css" rel="stylesheet" />
	<link rel="stylesheet" href="${r'${staticPath}'}/admin/lib/bootstrap-3.3.7-dist/css/bootstrap.min.css" />
	<link rel="stylesheet" href="${r'${staticPath}'}/admin/lib/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" />
	<link rel="stylesheet" href="${r'${staticPath}'}/admin/tcsf/tcsf.panel.css" />
	<link rel="stylesheet" href="${r'${staticPath}'}/admin/tcsf/content.css" />

	<script src="${r'${staticPath}'}/admin/tcsf/jquery.min.js"></script>
	<script type="text/javascript" src="${r'${staticPath}'}/admin/lib/bootstrap-3.3.7-dist/js/bootstrap.js" ></script>
	<script type="text/javascript" src="${r'${staticPath}'}/admin/lib/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js" ></script>
	<script type="text/javascript" src="${r'${staticPath}'}/admin/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" ></script>
	<script type="text/javascript" src="${r'${staticPath}'}/admin/lib/bootstrap-table/bootstrap-table.min.js" ></script>
	<script type="text/javascript" src="${r'${staticPath}'}/admin/lib/bootstrap-table/locale/bootstrap-table-zh-CN.min.js" ></script>
	<script type="text/javascript" src="${r'${staticPath}'}/admin/tcsf/content.js" ></script>
</head>
<body>

<div class="tpanel">
	<div class="panel-content">
		<div class="container-fluid">
			<div id="tool">
				<form id="searchForm" class="form-inline" onsubmit="return search('#searchForm','#table')" style="margin-top:20px;margin-bottom:20px;">
					<#list fields as field>
					<#if field.queryField>
					<div class="form-group">
						<label class="">${field.displayName}：</label>
						<input type="text" name="search_${field.queryCondition}${field.queryDataType}_${field.propertyName}" class="form-control"/>
					</div>
					</#if>
					</#list>
					<div class="form-group">
						<#if hasQueryField>
						<button type="submit" class="btn btn-primary radius">
							<span class="glyphicon glyphicon-search"></span> 查询
						</button>
						</#if>
						<a class="btn btn-success radius" href="${r'${ctx}'}${controllerUrl}/create">
							<span class="glyphicon glyphicon-cog"></span> 创建
						</a>
					</div>
				</form>
			</div>
			<table id="table"></table>
		</div>
	</div>
</div>

<script type="text/javascript">
    window.parent.changeTitle('${displayName}');

    $(function() {
        $('.form_datetime').datetimepicker({
            language : 'zh-CN',
            autoclose : true
        });
        $('#table').bootstrapTable({
            url: '${r'${ctx}'}${controllerUrl}/page-list',
            idField : 'id',
            striped : true,
            pagination : true,
            pageNumber : 1,
            pageSize : 25,
            sidePagination : 'server',
            uniqueId : 'id',
            /*checkbox : true,
            clickToSelect : true,*/
            queryParams : queryParams,
            responseHandler : responseHandler,
            columns: [/*{
                field: 'ck',
                checkbox : true
            },*/
			{
				title: '#',
				width : 50,
				align : 'center',
				formatter: snFormatter
			},
			<#list fields as field>
			<#if field.displayField>
			{
				field: '${field.propertyName}',
				searchable : true,
				sortable : true,
				title: '${field.displayName}',
				align : 'center'
			},
			</#if>
			</#list>  
			{
                field: 'op',
                searchable : true,
                title: '操作',
                align : 'center',
                formatter : operateFormatter
            }]
        });

    });

    function del(id,name) {
        window.parent.bootbox.prompt({
            title: "请输入您的管理密码以确定删除此系统资源",
            onEscape : true,
            backdrop : true,
            animate : true,
            buttons: {
                confirm: {
                    label: '删除',
                    className: 'btn-danger'
                },
                cancel: {
                    label: '取消',
                    className: ''
                }
            },
            inputType: 'password',
            callback: function (result) {
                if(result) {
                    $.post('${r'${ctx}'}${controllerUrl}/careful-delete',{id:id,password:result},function(resp) {
                        if(resp.code == 'OK') {
                            window.parent.layer.msg('删除成功', {icon: 1});
                            $('#table').bootstrapTable('refresh');
                        }else {
                            window.parent.layer.msg('删除失败:' + resp.message, {icon: 2});
                        }
                    },'json');
                }
            }
        });
    }

    function operateFormatter(value,row,index) {
		var content = '<a title="查看详情" href="javascript:detail(' + row.id + ')"><i class="iconfont icon-caidanguanli"></i></a>';
        content += '&nbsp;&nbsp;&nbsp;&nbsp;';
        content += '<a href="${r'${ctx}'}${controllerUrl}/update?id=' + row.id + '" title="编辑"><i class="iconfont icon-iconfontcolor32"></i></a>';
        content += '&nbsp;&nbsp;&nbsp;&nbsp;';
        content += '<a href="javascript:del(' + row.id + ')" title="删除"><i class="iconfont icon-shanchu"></i></a>';
        return content;
    }
	function detail(id) {
        window.parent.layer.open({
            type: 2,
            title: '查看详情',
            shadeClose: true,
            shade: [0.5, '#000'],
            area: ['800px', '500px'],
            content: '${r'${ctx}'}${controllerUrl}/detail?id=' + id
        });
	}
</script>

</body>
</html>
